package com.icode.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @Author: my_code
 * @Create: 2020-12-06 17:21
 */
@Configuration
public class MyRedissonConfig {

    /**
     * 所有对redis的操做都需要使用RedissonClient
     * @return
     * @throws IOException
     */
    @Bean(destroyMethod="shutdown")
    RedissonClient redisson() throws IOException {
        //创建配置
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://192.168.189.130:6379");
        //根据Config创建出RedissonClient实例
        return Redisson.create(config);
    }
}
